# coding:utf-8
# @Time    : 2025/2/8 11:23
# @Author  : liujingmao
# @FileName: ds-多轮对话.py

from openai import OpenAI


deepseek_key = "sk-420b9ef2cfcb489f918942371e4aeb47"

client = OpenAI(api_key=deepseek_key, base_url="https://api.deepseek.com")

# Round 1
messages = [{"role": "user", "content": "What's the highest mountain in the world?"}]
response = client.chat.completions.create(
    model="deepseek-chat",
    messages=messages
)

messages.append(response.choices[0].message)
print(f"Messages Round 1: {messages}")

# Round 2
messages.append({"role": "user", "content": "What is the second?"})
response = client.chat.completions.create(
    model="deepseek-chat",
    messages=messages
)

messages.append(response.choices[0].message)
print(f"Messages Round 2: {messages}")
